package hn.cch.custom;

import hn.cch.util.JsonUtil;
import org.apache.kafka.common.header.Headers;
import org.apache.kafka.common.serialization.Deserializer;

import java.nio.charset.StandardCharsets;
import java.util.Map;

public class CustomDeserializer implements Deserializer<CustomObject> {

    @Override
    public CustomObject deserialize(String s, byte[] bytes) {
        return JsonUtil.toObjectJackson(new String(bytes, StandardCharsets.UTF_8), CustomObject.class);
    }

    @Override
    public void configure(Map<String, ?> configs, boolean isKey) {

    }

    @Override
    public CustomObject deserialize(String topic, Headers headers, byte[] data) {
        return deserialize(topic, data);
    }

    @Override
    public void close() {

    }
}
